//
//  AlertV.m
//  LoveDraw
//
//  Created by 零零壹 on 2017/7/14.
//  Copyright © 2017年 梁晨. All rights reserved.
//

#import "AlertV.h"

@implementation AlertV

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        self.headBg = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
        self.headBg.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.2];
        [self addSubview:self.headBg];

        self.bottomV = [[UIView alloc]init];
        [self.headBg addSubview:self.bottomV];
        self.bottomV.backgroundColor = UIColors(0xEFEFEF);

        self.tapV = [[UIView alloc]init];
        [self.headBg addSubview:self.tapV];
        UITapGestureRecognizer *hiddenTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(Hidden)];
        [self.tapV addGestureRecognizer:hiddenTap];


        self.StudentInfo = [UIButton buttonWithType:(UIButtonTypeSystem)];
        [self.bottomV addSubview:self.StudentInfo];
        [self.StudentInfo setTitle:@"学生信息" forState:(UIControlStateNormal)];
        [self.StudentInfo setTitleColor:UIColors(0x444444) forState:(UIControlStateNormal)];
        self.StudentInfo.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Thin" size:17];
        [self.StudentInfo addTarget:self action:@selector(InfoAct) forControlEvents:(UIControlEventTouchUpInside)];
        self.StudentInfo.backgroundColor = [UIColor whiteColor];


        self.LiuYanBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
        [self.bottomV addSubview:self.LiuYanBtn];
        [self.LiuYanBtn setTitle:@"留言" forState:(UIControlStateNormal)];
        [self.LiuYanBtn setTitleColor:UIColors(0x444444) forState:(UIControlStateNormal)];
        self.LiuYanBtn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Thin" size:17];
        [self.LiuYanBtn addTarget:self action:@selector(LiuYanAct) forControlEvents:(UIControlEventTouchUpInside)];
        self.LiuYanBtn.backgroundColor = [UIColor whiteColor];

        self.reportBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
        [self.bottomV  addSubview:self.reportBtn];
        [self.reportBtn setTitle:@"学习小结" forState:(UIControlStateNormal)];
        [self.reportBtn setTitleColor:UIColors(0x444444) forState:(UIControlStateNormal)];
        self.reportBtn.titleLabel.font = [UIFont fontWithName:@"Ping-Fang-SC-Thin" size:17];
        [self.reportBtn addTarget:self action:@selector(reportAct) forControlEvents:(UIControlEventTouchUpInside)];
        self.reportBtn.backgroundColor = [UIColor whiteColor];

        self.chengzhangRecordBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
        [self.bottomV addSubview:self.chengzhangRecordBtn];
        [self.chengzhangRecordBtn setTitle:@"成长记录" forState:(UIControlStateNormal)];
        [self.chengzhangRecordBtn setTitleColor:UIColors(0x444444) forState:(UIControlStateNormal)];
        self.chengzhangRecordBtn.titleLabel.font = [UIFont fontWithName:@"Ping-Fang-SC-Thin" size:17];
        [self.chengzhangRecordBtn addTarget:self action:@selector(ChengzhangAct) forControlEvents:(UIControlEventTouchUpInside)];
        self.chengzhangRecordBtn.backgroundColor = [UIColor whiteColor];



        self.CancelBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
        [self.bottomV  addSubview:self.CancelBtn];
        [self.CancelBtn setTitle:@"取消" forState:(UIControlStateNormal)];
        [self.CancelBtn setTitleColor:UIColors(0x444444) forState:(UIControlStateNormal)];
        [self.CancelBtn addTarget:self action:@selector(CancelAct) forControlEvents:(UIControlEventTouchUpInside)];
        self.CancelBtn.backgroundColor = [UIColor whiteColor];
    }
    return self;
}


// @property(nonatomic,strong)UIView *headBg;
//@property(nonatomic,strong)UIView *tapV;
//@property(nonatomic,strong)UIView *bottomV;
//@property(nonatomic,strong)UIButton *LiuYanBtn;
//@property(nonatomic,strong)UIButton *reportBtn;
//@property(nonatomic,strong)UIButton *CancelBtn;



-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.headBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.top.equalTo(self.mas_top);
        make.bottom.equalTo(self.mas_bottom);
    }];

    [self.bottomV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
    }];

    [self.tapV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.top.equalTo(self.mas_top);
        make.bottom.equalTo(self.bottomV.mas_top);
    }];

    [self.CancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.height.mas_equalTo(45);
    }];

    [self.chengzhangRecordBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.CancelBtn.mas_top).offset(-10);
        make.height.mas_equalTo(45);
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
    }];

    [self.reportBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.chengzhangRecordBtn.mas_top).offset(-2);
        make.height.mas_equalTo(45);
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
    }];


    [self.LiuYanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.bottom.equalTo(self.reportBtn.mas_top).offset(-2);
        make.height.mas_equalTo(45);
    }];

    [self.StudentInfo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.height.mas_equalTo(45);
        make.bottom.equalTo(self.LiuYanBtn.mas_top).offset(-2);
        make.top.equalTo(self.bottomV.mas_top);

    }];

}

-(void)InfoAct
{

    [self.Delegate AlertDidSelect:3];
    [self Hidden];
}
/**
 留言的方法
 */
-(void)LiuYanAct
{
    [self.Delegate AlertDidSelect:0];
    [self Hidden];
}

/**
 学习报告
 */
-(void)reportAct
{
    [self.Delegate AlertDidSelect:1];
    [self Hidden];
}


/**
 成长记录
 */
-(void)ChengzhangAct
{
    [self.Delegate AlertDidSelect:2];
    [self Hidden];
}

/**
 取消的方法
 */
-(void)CancelAct
{
    [self Hidden];
}

// 隐藏的方法
-(void)Hidden
{
    [UIView animateWithDuration:0.5 animations:^{
         self.alpha = 0;
    }];

}

// 出现的方法
-(void)Apper
{
    [UIView animateWithDuration:0.5 animations:^{
        self.alpha = 1;
    }];
}

//









@end
